package com.airclick.merchant.service.impl;

import com.airclick.merchant.service.TransactionDataService;
import com.airclick.merchant.serviceFeign.AuditCheckServiceFeign;
import com.airclick.merchant.serviceFeign.BrandServiceFeign;
import com.airclick.merchant.serviceFeign.TransactionDataServiceFeign;
import com.airclick.merchant.utils.CommonResult;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Transactional(rollbackFor=Exception.class)
@Service
public class TransactionDataServiceImpl implements TransactionDataService {

    @Resource
    private TransactionDataServiceFeign transactionDataServiceFeign;

    @Resource
    private AuditCheckServiceFeign auditCheckServiceFeign;

    @Resource
    private BrandServiceFeign brandServiceFeign;


    @Override
    public Map<String, Object> selectacount(String adminId , String days) {

        Map<String,Object> map = new HashMap<>();
        List<Object> list = new ArrayList<>();
        //查询出当天的交易数据
        CommonResult acount = transactionDataServiceFeign.selectgame(adminId);
        if (acount == null) {
            map.put("acount","没有数据");
        }else{
            list.add(acount.getData());
            map.put("acount",list);
        }
        //查询出该商户下有多少待审核状态的商品
        CommonResult audi = auditCheckServiceFeign.selectgame("0",adminId);
        if (audi == null) {
            map.put("audipro","没有数据");
        }else {
            map.put("audipro",audi.getData());
        }
//        List<Object> listaudi = new ArrayList<>();
        //查询出该商户下有多少待审核状态的品牌
        CommonResult brand = brandServiceFeign.selectbrand("0",adminId);
        if (brand == null) {
            map.put("audibrand","没有数据");
        }else {
            map.put("audibrand",brand.getData());
        }
//        List<Object> listbrand = new ArrayList<>();
        CommonResult historylist = transactionDataServiceFeign.selectsudi(adminId,days);
        if (historylist == null) {
            map.put("history","没有数据");
        }else {
            map.put("history",historylist.getData());
        }

        return map;
    }
}
